package filterStream;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class FilterDemo02 {
    public String username;
    public String password;

    public FilterDemo02() {
    }

    public FilterDemo02(String username, String password) {
        this.username = username;
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "FilterDemo02{" +
                "username='" + username + '\'' +
                ", password='" + password + '\'' +
                '}';
    }

    public static void main(String[] args) {
        FilterDemo02 user01 = new FilterDemo02("aoyuan","123");
        FilterDemo02 user02 = new FilterDemo02("yuan","234");
        FilterDemo02 user03 = new FilterDemo02("ao","345");

        List<FilterDemo02> list  = new ArrayList<>();
        list.add(user01);
        list.add(user02);
        list.add(user03);
        //查找username = aoyuan的
        List<FilterDemo02> collect = list.stream().filter(n -> n.getUsername().equals("aoyuan")).collect(Collectors.toList());
        collect.forEach(System.out::println);
                System.out.println("------------------------------------------------------------------------------");

         //查找username =ao
         List<FilterDemo02> collect01 = list.stream().filter(n -> n.getUsername().equals("ao")).collect(Collectors.toList());
         collect01.forEach(System.out::println);
        System.out.println("------------------------------------------------------------------------------");
         List<FilterDemo02> collect02 = list.stream().filter(n -> n.getPassword() != "123").collect(Collectors.toList());
         collect02.forEach(System.out::println);
    }
}
